/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 26727
 * Date: 2025-10-07
 * Time: 23:03
 */
public class TestH4 {
    public static int removeDuplicates(int[] num) {
        int n = num.length;
        int i = 1, count = 1;
        while(i < n) {
            if(num[i-1] == num[i]) {
                count++;
            }else {
                count = 1;
            }
            if(count > 2) {
                for(int j = i; j < n-1; j++) {
                    num[j] = num[j+1];
                }
                i--;
                n--;
            }
            i++;
        }
        return n;
    }
    public static void main(String[] args) {
        int[] num = {1,1,1,2,2,3};
        int ret = removeDuplicates(num);
        System.out.println(ret);
    }
}
